<?php 

foreach($this->vote_info as $thread_id=>$thread){
    $vote_list = array();
    if(count($thread) >= 1 && $thread_id != 2){
    global $total_vote_sms, $total_vote_web;
        $total_vote_sms = 0;
        $total_vote_web = 0;
        foreach($thread as $phase_id=>$phase){
            $now = time();
            if($phase->vote_start_time <= $now && $phase->vote_end_time >= $now){
            
                $vote_list = $this->photoList[$phase->thid][$phase->pid];
                
                break;
            }
        }
        
        if(empty($vote_list)) $vote_list = $this->photoList[$phase->thid][$phase->pid];
        
        if(count($vote_list) > 0){
            foreach($vote_list as $imgObj){
                
                $total_vote_sms=$total_vote_sms + $imgObj->vote_sms_count;
                $total_vote_web=$total_vote_web + $imgObj->vote_web_count;
            }
            reset($vote_list);
        }
        //eprint(array(count($vote_list), $total_vote_sms, $total_vote_web));
    // Sort array
    if(is_array($vote_list) && count($vote_list) > 0)
        usort($vote_list, "double_vote_cmp");

    $photo_block_id = $thread_id."_".$phase_id;
    $photo_block_title = "Top 10 ".$phase->thread_name.($phase->phase_name != ""?" - ".$phase->phase_name:"");

?>
            <div id="topten" class="nen_menu_left">
                <div class="menu_left2">
                    <div class="tex_menu_left">
                        <span class="value"><?=$photo_block_title?></span>
                    </div>
                    <div class="tex_top_10">
                        <ol class="topten">
                            <?php 
                            for($i=0; $i<count($vote_list) && $i<10; $i++){
                                $voteObj = $vote_list[$i];
                            ?>
                            <li><a href="http://photo.tamtay.vn/photo/view/<?php echo $voteObj->aid?>"><?php echo $voteObj->album_name." (".$voteObj->t."%)"?></a></li>
                         <?php        
                            }
                        ?>
                      </ol>
                        
                    </div>
                    <div class="chitiet">
                        <a href="<?php echo "/event/".$event->short_cut."/votedalbumlist/$thread_id/$phase_id";?>">Xem hết &raquo;</a>
                    </div>
                    <div class="clear"></div>
                </div>
            </div>  
                    
<?php 
    } // End of If
}// End of for loop ?>